package com.leifeng.demo.WindowDemo.controller;

import java.net.URL;
import java.util.ResourceBundle;

import com.leifeng.demo.WindowDemo.main.StageManager;

import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.fxml.Initializable;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.TextField;
import javafx.stage.Stage;

public class FirstController implements Initializable {
	
    @FXML TextField txtData;

    @FXML
    private Button btnOpenTwoWin;

	@Override
	public void initialize(URL location, ResourceBundle resources) {
		// TODO Auto-generated method stub
		
	}
	
	@FXML
	private void open(ActionEvent event) throws Exception{
		Stage stage = new Stage();
		Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("view/SecondView.fxml"));
		stage.setTitle("第二个窗口");
		stage.setResizable(false);
		stage.setScene(new Scene(root));
		stage.initOwner(btnOpenTwoWin.getScene().getWindow());
		stage.show();
		//将第二个窗口保存到map中
		StageManager.STAGE.put("second", stage);
		StageManager.CONTROLLER.put("firstController", this);
	}

}
